Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms

Public Partial Class FrmListadoGralRemitos
    Inherits Form
    Dim pedidos As New DAOPedido
	Public Sub New()
		InitializeComponent()
		groupBoxAvanzada.Enabled = False
	End Sub

	Private Sub button1_Click(sender As Object, e As EventArgs)
		cargarGrillaPedido()
	End Sub

	Private Sub ckbAvanzada_CheckedChanged(sender As Object, e As EventArgs)
		If chbAvanzada.Checked Then
			groupBoxAvanzada.Enabled = True
		Else
			groupBoxAvanzada.Enabled = False
		End If
	End Sub

	Private Sub FrmListadoGralPedidos_Load(sender As Object, e As EventArgs)

	End Sub

	Private Sub cargarGrillaPedido()
		Dim nro As System.Nullable(Of Integer)
		Dim estadoDoc As System.Nullable(Of Integer)
		Dim razonSocial As String = txtRazonSocial.Text
		Dim obra As String = txtObra.Text
		Dim fecha As System.Nullable(Of DateTime)

		If txtNroPedido.Text <> "" Then
			nro = Integer.Parse(txtNroPedido.Text)
		Else
			nro = Nothing
		End If

		If mktFecha.Text <> "  /  /" Then
			fecha = DateTime.Parse(mktFecha.Text)
		Else
			fecha = Nothing
		End If

		If cmbEstado.SelectedIndex <> -1 Then
			estadoDoc = cmbEstado.SelectedIndex + 1
		Else
			estadoDoc = Nothing
		End If
        dgvPedidos.DataSource = pedidos.DAOBuscarPedidoGeneral(nro, razonSocial, fecha, obra, estadoDoc)
	End Sub

	Private Sub dgvPedidos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
		Dim nro As Integer = 0
		nro = Integer.Parse(dgvPedidos.CurrentRow.Cells(0).Value.ToString())
	End Sub

End Class
